<%-- 
    Document   : postmanage
    Created on : Feb 28, 2015, 4:51:41 PM
    Author     : quanhungbang
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!<!DOCTYPE html>
<html>
    <head>
        <title>HTML5/CSS3 Responsive Theme</title>
        <meta charset="utf-8"/>

        <link rel="stylesheet" href="css/postmanage.css" type="text/css" />
    </head>

    <body class="body">
        <form action="PostManagementServlet" method="post">
            <header class="mainHeader">
                <nav>
                    <ul>
                        <li><a href="#">View Post</a></li>
                        <li class="active"><a href="#">New Post</a></li>
                    </ul>
                </nav>
            </header>
            <div class="filter">
                <ul>
                    <li>Search Post</li>
                    <li><input type="text" name="s" value=""/></li>
                    <li class="last"><input type="submit" value="search" name="action"/></li>
                </ul>
            </div>
            <table border="2">
                <tr>
                    <td>AccountID</td> <td>Title</td> <td>Content</td> <td>Address</td> <td>Country</td> 
                    <td>Price</td> <td>Date Post</td> <td>Image</td> <td>Check</td>
                </tr>

                <c:choose>
                    <c:when test="${fn:length(result) gt 0}">
                        <c:forEach items="${requestScope.result}" var="p">
                            <tr>
                                <td>${p.post_id}</td> <td>${p.title}</td> <td>${p.content}</td> <td>${p.address}</td> <td>${p.city}</td> 
                                <td>${p.price}</td> <td>${p.created_date}</td> <td><img src="images/pg1.jpg" width="50" height="50"></td> 
                                <td><input type="checkbox" value="${p.post_id}" name="selected" /></td>
                            </tr>
                        </c:forEach>
                    </c:when>
                    <c:otherwise>
                        <c:forEach items="${requestScope.posts}" var="p">
                            <tr>
                                <td>${p.post_id}</td> <td>${p.title}</td> <td>${p.content}</td> <td>${p.address}</td> <td>${p.city}</td> 
                                <td>${p.price}</td> <td>${p.created_date}</td> <td><img src="images/pg1.jpg" width="50" height="50"></td> 
                                <td><input type="checkbox" value="${p.post_id}" name="selected" /></td>
                            </tr>
                        </c:forEach>
                    </c:otherwise>
                </c:choose>


                <tr>
                    <td>AC002</td> <td>Banh kem loai 1</td> <td>Banh kem cua hang dong tien</td> <td>56 Phan Chau Trinh - Da Nang</td> <td>Viet Nam</td> 
                    <td>234000</td> <td>20-5-2105</td> <td><img src="images/pg1.jpg" width="50" height="50"></td> 
                    <td><input type="checkbox" value="" name="" /></td>
                </tr>
            </table>

            <div class="error">
                <c:out value="${requestScope.error}"></c:out>
            </div>
            <div class="mainButton">
                <input type="submit" value="Delete post selected items" name="delete" />
            </div>
        </form>
    </body>
</html>

